package com.company.cloud.point.modules.app.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.company.cloud.common.asserts.ValidatorUtils;
import com.company.cloud.common.auth.annotation.Authc;
import com.company.cloud.common.auth.annotation.Login;
import com.company.cloud.common.bean.BaseResult;
import com.company.cloud.common.bean.LoginSimpleUserInfo;
import com.company.cloud.common.utils.AuthContextUtils;
import com.company.cloud.point.modules.app.controller.req.PointProcessParam;
import com.company.cloud.point.modules.cache.models.PointRuleConfigModel;
import com.company.cloud.point.modules.mgr.controller.req.PointRuleConfigQuery4PageParam;
import com.company.cloud.point.modules.mgr.service.PointRuleConfigMgrService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Log4j2
@Login
@RestController
@RequestMapping("/app/point")
@Api(tags="APP_积分服务")
public class PointAppController {

    @Autowired
    private PointRuleConfigMgrService pointRuleConfigMgrService;

    @PostMapping("/eventProcess")
    @ApiOperation(value="积分规则处理", response= BaseResult.class)
    public BaseResult pointEventProcess(@RequestBody PointProcessParam params) {
        LoginSimpleUserInfo userInfo = AuthContextUtils.getUser();
        params.setCompanyNo(userInfo.getCompanyNo());
        params.setUserId(userInfo.getId());
        ValidatorUtils.validate(params);
        pointRuleConfigMgrService.process(params,userInfo);
        return BaseResult.ok();
    }

}
